import React from 'react'
export default class App extends React.Component {
  state = {
    obj: { aa: 11 },
    newobj: {},
  }
  //   值类型：count :1,
  // number:1
  // []===[] {}==={} false
  // 创建了新的数组 new Array new Object
  componentDidMount() {
    this.setState(
      //   { newobj: this.state.obj }, () => {
      //   console.log(this.state.newobj === this.state.obj) //true ,内存地址一样，修改obj数据会影响到newobj
      // }
      {
        newobj: { ...this.state.obj },
      },
      () => {
        console.log(this.state.newobj === this.state.obj) //false
      }
    )
  }
  render() {
    return (
      <>
        <h1>React的this.setstate异步更新</h1>
        {/* <button onClick={this.countHandle}>点击</button> */}
        {/* <h2>{this.state.count}</h2> */}
      </>
    )
  }
}
